package com.doit.day02;

import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.*;
import org.apache.hadoop.hbase.filter.PrefixFilter;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Iterator;

public class _10_scan数据 {
    public static void main(String[] args) throws IOException {
        Connection conn = HbaseUtil.getConn();
        Table table = conn.getTable(TableName.valueOf("doit:table_name"));

        PrefixFilter prefixFilter = new PrefixFilter("abc".getBytes(StandardCharsets.UTF_8));

        Scan scan = new Scan("a".getBytes(StandardCharsets.UTF_8),prefixFilter);

        ResultScanner scanner = table.getScanner(scan);


        Iterator<Result> iterator = scanner.iterator();
        while (iterator.hasNext()){
            Result next = iterator.next();
            while (next.advance()){
                Cell current = next.current();
                System.out.println("行键是："+new String(CellUtil.cloneRow(current)));
                System.out.println("列族是："+new String(CellUtil.cloneFamily(current)));
                System.out.println("列是："+new String(CellUtil.cloneQualifier(current)));
                System.out.println("值是："+new String(CellUtil.cloneValue(current)));
                System.out.println("========瑞哥帅========");
            }
        }

    }
}
